package com.jiker.order;

import com.jiker.Area;
import com.jiker.Coordinates;

/**
 * @author leo
 */
public class OverStepHandler {
    static Coordinates overStepHandler(Coordinates coordinates, Area area) {
        if (area.contains(coordinates)) {
            return coordinates;
        }
        switch (coordinates.getDirection()) {
            case SOUTH:
                coordinates.setY(-(coordinates.y() + 1));
                break;
            case NORTH:
                coordinates.setY(-(coordinates.y() - 1));
                break;
            case EAST:
                coordinates.setX(-(coordinates.x() - 1));
                break;
            case WEST:
                coordinates.setX(-(coordinates.x() + 1));
                break;
            default:
                break;
        }
        return coordinates;
    }
}